package com.zft.userwalletmanager.infrastructure.common.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

@Getter
public enum TransferTypeEnums {
    TRANSFER("TRANSFER","转账"),
    DEBIT("DEBIT","加款"),
    CREDIT("CREDIT","扣款"),;
    private String code;
    private String message;

    TransferTypeEnums(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static TransferTypeEnums getOfCode(String code) {
        if (StringUtils.isBlank(code)) {
            throw new IllegalArgumentException("code is blank");
        }
        TransferTypeEnums[] values = TransferTypeEnums.values();
        for (TransferTypeEnums value : values) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        throw new IllegalArgumentException("no find TransferTypeEnum");
    }

    public static TransferTypeEnums getOfMessage(String message) {
        if (StringUtils.isBlank(message)) {
            throw new IllegalArgumentException("message is blank");
        }
        TransferTypeEnums[] values = TransferTypeEnums.values();
        for (TransferTypeEnums value : values) {
            if (value.getMessage().equals(message)) {
                return value;
            }
        }
        throw new IllegalArgumentException("no find TransferTypeEnum");
    }
}
